Skip to content

Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF - #9997

Open
sayyanna wants to merge 8 commits into
Xilinx:masterfrom
sayyanna:coredump_elf
Open

Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF#9997
sayyanna wants to merge 8 commits into
Xilinx:masterfrom
sayyanna:coredump_elf

Conversation

@sayyanna

@sayyanna sayyanna commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Problem solved by the commit

Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF

Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered

Add get_aie_coredump_elf() API for generating coredump (ET_CORE) ELF. Currently AIE coredump is generated as a raw bin file, but this PR enables generated of coredump in ELF format. The existing get_aie_coredump() raw blob API will be deprecated.

How problem was solved, alternative solutions (if any) and why they were rejected

Added new API that package a raw AIE coredump blob into an ET_CORE ELF using the AIEBU coredump ELF writer:
std::vector
get_aie_coredump_elf(std::optionalxrt::aie::coredump_meta meta = std::nullopt) const;

The AIE architecture is derived from the ELF loaded in this context. Metadata (timestamp, versions, device info, uuid) is always embedded. If @meta is provided it is used as-is; otherwise metadata is built internally from the hw_context and device.
The coredump ELF packaging logic lives in xrt_elf.cpp and is exposed internally via xrt_core::elf_int::make_aie_coredump_elf, keeping xrt_hw_context.cpp free of any direct aiebu dependency.

Packaging the dump as an ET_CORE ELF solves:

  • Self-describing: the ELF header encodes the AIE architecture via the OS/ABI byte, so debuggers and analysis tools can identify the target without extra context
  • Metadata-rich: a dedicated ELF note section carries timestamp, firmware version, device info, ELF UUID, and context state at capture time — critical for correlating a dump with the exact firmware image and system state
  • Integration: callers like XDP can call get_aie_coredump_elf() directly and hand off a self-contained artifact without needing to know anything about the underlying architecture

Risks (if any) associated the changes in the commit

None

What has been tested and how, request additional testing if necessary

Added below setting in xrt.ini
[Runtime]
aie_coredump_file = aie_coredump.elf

Enabled coredump: xrt-smi configure --advanced --auto-coredump --enable
then triggered ERT_COM_STATE_TIMEOUT, coredump is ELF generated.

Documentation impact (if any)

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@stsoe stsoe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment the code, structs, etc.

Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_hw_context.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_hw_context.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/include/xrt/xrt_hw_context.h Outdated
Comment thread src/runtime_src/core/include/xrt/xrt_hw_context.h Outdated
@stsoe

stsoe commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

One more question, who is the consumer of these new APIs? If it is XDP, I would argue that they should add this code themselves. E.g. first get the raw coredump from XRT, then re-package it using aiebu.

@larry9523 larry9523 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few high level comments

  1. please add some detail in the PR description about why are we doing this.
  2. I would suggest we only provide one public API get_aie_coredump_elf() internally it will create an ELF coredump with metadata. It does not hurt to add metadata into ELF. (Thanks @stsoe for the input)
  3. I think there is no consumer of xrt.ini path to create aie coredump (I confirm this with @IshitaGhosh and @jvillarre). So while we keep our xrt::hw_context::get_aie_coredump() API, we should generate ELF format coredump with metadata for the xrt,ini path.

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@sayyanna
sayyanna requested review from larry9523 and stsoe August 27, 2026 19:03
Comment thread src/runtime_src/core/include/xrt/xrt_hw_context.h Outdated
Comment thread src/runtime_src/core/common/api/xrt_hw_context.cpp
Comment thread src/runtime_src/core/include/xrt/experimental/xrt_aie_coredump.h Outdated
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Comment thread src/runtime_src/core/common/api/xrt_elf.cpp
Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_hw_context.cpp
if (!ostr)
throw std::runtime_error("Could not open '" + file + "' for writing");
ostr.write(core.data(), static_cast<std::streamsize>(core.size()));
std::abort();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was a mention that we should not abort on coredump, but the original spec said we should. I want to make sure remove std::abort() is indeed correct.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the std::abort() to make sure driver clean up hw_context after timeout. We don't have to get the exception message and coredump() at one run. When usesrs set xrt.ini to save aie coredump, they already see the timeout and exception message.

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@sayyanna
sayyanna requested a review from stsoe August 28, 2026 21:51
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@stsoe stsoe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Minor corrections.

Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_elf.cpp Outdated
Comment thread src/runtime_src/core/common/api/xrt_hw_context.cpp Outdated
Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@sayyanna
sayyanna requested a review from stsoe August 30, 2026 06:35
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@larry9523 larry9523 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some minor suggestions.

* get_aie_coredump_elf() - Returns the coredump of AIE Array as an ET_CORE ELF.
* Fetches the raw AIE dump blob and packages it into a coredump ELF.
* The AIE architecture is derived from the ELF loaded in this context.
* Metadata (timestamp, firmware version, device info, ELF UUID) is always

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UUID is not always present.

// Write AIE coredump ELF to the configured file then abort.
// std::abort() ensures the OS reclaims driver resources (hw_context, hardware
// state) after a timeout. Users who set xrt.ini to capture AIE coredump
// have already observed the timeout exception on a prior run.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "Users who..." is a regular working flow but not the code itself. You can make it clear that users would see either coredump w/ xrt.ini or exception message w/o xrt.ini

// Each ELF has its own UUID; using the run's module ensures the
// correct UUID is embedded in the coredump metadata.
if (!m_module)
throw std::runtime_error("AIE coredump ELF not available: no ELF associated with this run");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the xrt.ini only applies to full elf flow? If so, you may want to make it clear in the comments

get_aie_coredump() const;

/**
* get_aie_coredump_elf() - Returns the coredump of AIE Array as an ET_CORE ELF.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* get_aie_coredump_elf() - Returns the coredump of AIE Array as an ET_CORE ELF.
* get_aie_coredump_elf() - Returns the coredump of AIE Array as an ELF (e_type = ET_CORE)

Signed-off-by: Sri Latha Ayyannagari <SriLatha.Ayyannagari@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants